package com.supreme.studyserver.service.mall;

import com.supreme.studyserver.service.MallService;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Service
public class SuperMallService {

    @Resource
    private List<MallService> mallService;

    private Map<String, MallService> mallServiceHash;

    @PostConstruct
    private void initSuperMallService() {
        mallServiceHash = mallService.stream().collect(Collectors.toMap(MallService::getMallName, Function.identity()));
    }

    public MallService getMallService(String mallName) {
        return mallServiceHash.get(mallName);
    }
}
